import { Component, OnInit } from '@angular/core';
import { InfiniteScrollCustomEvent } from '@ionic/angular';

import * as Parse from "parse"
import {  Router } from '@angular/router';
(Parse as any).serverURL = "http://metapunk.cn:9999/parse"
Parse.initialize("dev")
@Component({
  selector: 'app-video',
  templateUrl: './message.component.html',
  styleUrls: ['./message.component.scss']
})
export class MessageComponent implements OnInit {
  userList: any = [];

  async ngOnInit(): Promise<void> {
    this.generateUserList();
  }

  async generateUserList() {
    for(let i=0 ;i<2;i++){
      let query = new Parse.Query("BRBUser")
      query.limit(30)
      let slist:any = await query.find()

      console.log(slist)
      
      slist = slist.map((item:any)=>item.toJSON())
      this.userList = this.userList.concat(slist);   
    }
  }

  

  onIonInfinite(ev: any) {
    this.generateUserList();
    setTimeout(() => {
      (ev as InfiniteScrollCustomEvent).target.complete();
    }, 500);
  }
  constructor(private router:Router){

  }
  chat(){
    this.router.navigate(["/BigRedBook/message/chat"], {
    })
  }
}
